package admin

import (
	"strconv"
	"strings"

	"github.com/astaxie/beego"
)

type IndexController struct {
	beego.Controller
}

func GetUserIdBySession(c *IndexController) (int, bool) {
	str := c.Ctx.Input.Session(SessionKey)
	if str == nil {
		return 0, false
	}
	strs := strings.Split(str.(string), ":")
	if strs == nil || len(strs) != 4 {
		return 0, false
	}
	id , err := strconv.Atoi(strs[1])
	if err != nil {
		return 0, false
	}
	return id, true
}

func (c *IndexController) Get() {
	c.TplName = "admin/index.html"
}